package com.saltedfish.tool.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.saltedfish.tool.handler.NotificationUtil;
import com.saltedfish.tool.handler.NotifyObject;

import java.io.IOException;

public class AlarmReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if("TIMER_ACTION".equals(intent.getAction())){
            String str = intent.getStringExtra("KEY_NOTIFY");
            NotifyObject obj = null;
            try {
                obj = NotifyObject.from(str);
                if(obj != null){
                    NotificationUtil.notifyByAlarmByReceiver(context,obj);//立即开启通知
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
}
